package lbj.cyw.dp;
/*
* 47. 礼物的最大值
*
* */
public class Offer47maxValue {
    public int maxValue(int[][] grid) {
        int m=grid.length;
        int n=grid[0].length;
        int[] dp=new int[n+1];
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                dp[j+1]=Math.max(dp[j+1],dp[j])+grid[i][j];
            }
        }
        return dp[n];
    }
}
